package org.jsola.hr.helper;

import org.jsola.hr.constant.EmpInfoRequireType;
import org.jsola.hr.constant.EmpInfoScene;
import org.jsola.hr.dto.EmpCardRequireAddDTO;
import org.jsola.hr.dto.EmpCardRequireUpdateDTO;
import org.jsola.hr.entity.EmpCardRequireDO;
import org.jsola.hr.query.EmpCardRequireQuery;
import org.jsola.hr.service.IEmpCardRequireService;
import org.jsola.hr.vo.EmpCardRequireVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;

import java.util.List;

import static org.jsola.hr.core.AbstractTest.SITE_ID;



/**
 * @author zhr
 */
@Component
public class EmpCardRequireTestHelper extends BaseTestHelper {
    
    @Autowired
    private IEmpCardRequireService empCardRequireService;

    /**
     * 生成add测试数据
     * @return EmpCardRequireAddDTO
     */
    public EmpCardRequireAddDTO getEmpCardRequireAddDTO(){
        EmpCardRequireAddDTO empCardRequireAddDTO = new EmpCardRequireAddDTO();
        empCardRequireAddDTO.setCompanyId(getRandomValue("varchar",32));
        empCardRequireAddDTO.setRequireType(EmpInfoScene.ENTRY.getValue());
        empCardRequireAddDTO.setType(EmpInfoRequireType.NO_NEED.getValue());
        empCardRequireAddDTO.setNumber(EmpInfoRequireType.NO_NEED.getValue());
        empCardRequireAddDTO.setPhoto(EmpInfoRequireType.NO_NEED.getValue());
        return empCardRequireAddDTO;
    }


    /**
     * 生成update测试数据
     * @return EmpCardRequireUpdateDTO
     */
    public EmpCardRequireUpdateDTO getEmpCardRequireUpdateDTO(EmpCardRequireVO empCardRequireVO){
        return empCardRequireService.selectDOById(empCardRequireVO.getId(), SITE_ID).to(EmpCardRequireUpdateDTO.class);
    }

    /**
     * 生成查询数据
     * @return EmpCardRequireQuery
     */
    public EmpCardRequireQuery getEmpCardRequireQuery() {
        EmpCardRequireQuery empCardRequireQuery = new EmpCardRequireQuery();
        List<EmpCardRequireDO> empCardRequireDOList = empCardRequireService.list(new EmpCardRequireDO(),SITE_ID);
        if (!CollectionUtils.isEmpty(empCardRequireDOList)) {
            EmpCardRequireDO empCardRequireDO = empCardRequireDOList.get(0);
            empCardRequireQuery = empCardRequireDO.to(EmpCardRequireQuery.class);
        }
        return empCardRequireQuery;
    }

    /**
     * 保存示例
     * @return EmpCardRequireVO
     */
    public EmpCardRequireVO saveEmpCardRequireExample(){
        EmpCardRequireAddDTO addDTO = this.getEmpCardRequireAddDTO();
        EmpCardRequireVO empCardRequireVO = empCardRequireService.save(addDTO,buildTokenUser());
        return empCardRequireVO;
    }


}

